﻿using Newtonsoft.Json.Linq;
using System.Collections.Generic;
using static System.Windows.Forms.VisualStyles.VisualStyleElement.StartPanel;

namespace OnlineStore
{
    /// <summary>
    /// 任务
    /// </summary>
    public class PlayerTask
    {
        public PlayerTask() { }

        private JObject pathConfig;

        private JObject pwSettingConfig;

        private string rootPath = string.Empty;

        private string type = string.Empty;

        private string user = string.Empty;

        private string password = string.Empty;

        private string id = string.Empty;

        private string modelBaby = string.Empty;

        private string title = string.Empty;

        private string cookie = string.Empty;

        private string logPath = string.Empty;

        private string otherName = string.Empty;

        private int count = 0;

        private int delay = 0;

        private int timeInterval = 0;

        private int save = 0;

        private int titleDelay = 0;

        private List<string> titleList;

        private List<string> picList;

        private Dictionary<string,string> carMap = new Dictionary<string, string>();

        /// <summary>
        /// 获取网店类型
        /// </summary>
        public string Type { get => type; set => type = value; }
        /// <summary>
        /// 账号
        /// </summary>
        public string User { get => user; set => user = value; }
        /// <summary>
        /// 密码
        /// </summary>
        public string Password { get => password; set => password = value; }
        /// <summary>
        /// 账号ID
        /// </summary>
        public string Id { get => id; set => id = value; }
        /// <summary>
        /// 模板宝贝ID
        /// </summary>
        public string ModelBaby { get => modelBaby; set => modelBaby = value; }
        /// <summary>
        /// 标题文件
        /// </summary>
        public string TitlePath { get => title; set => title = value; }
        /// <summary>
        /// 发布数量
        /// </summary>
        public int Count { get => count; set => count = value; }
        /// <summary>
        /// 获取浏览器导航
        /// </summary>
        public JObject PathConfig { get => pathConfig; set => pathConfig = value; }
        /// <summary>
        /// 发布延迟
        /// </summary>
        public int Delay { get => delay; set => delay = value; }
        /// <summary>
        /// 宝贝标题列表
        /// </summary>
        public List<string> TitleList { get => titleList; set => titleList = value; }
        /// <summary>
        /// 车型图片列表
        /// </summary>
        public List<string> PicList { get => picList; set => picList = value; }
        /// <summary>
        /// 车型图片：车型标题，导航
        /// </summary>
        public Dictionary<string, string> CarMap { get => carMap; set => carMap = value; }
        /// <summary>
        /// 登录记录文件名
        /// </summary>
        public string Cookie { get => cookie; set => cookie = value; }
        /// <summary>
        /// 已使用标题地址
        /// </summary>
        public string LogPath { get => logPath; set => logPath = value; }

        /// <summary>
        /// playwrigth 初始配置
        /// </summary>
        public JObject PwSettingConfig { get => pwSettingConfig; set => pwSettingConfig = value; }
        
        /// <summary>
        /// 网店发布间隔时间
        /// </summary>
        public int TimeInterval { get => timeInterval; set => timeInterval = value; }

        /// <summary>
        /// 保存登录记录
        /// </summary>
        public int Save { get => save; set => save = value; }

        /// <summary>
        /// 设置/获取 标题输入延迟
        /// </summary>
        public int TitleDelay { get => titleDelay; set => titleDelay = value; }

        /// <summary>
        /// 标题文件目录
        /// </summary>
        public string RootPath { get => rootPath; set => rootPath = value; }

        /// <summary>
        /// 用户名别名
        /// </summary>
        public string OtherName
        {
            get { return otherName; }
            set
            {
                if (value.Contains(":"))
                {
                    value = value.Split(':')[0];
                }
                otherName = value;
            }
        }

        /// <summary>
        /// 异常截图目录
        /// </summary>
        public string ErrPicPath
        {
            get { return $"{RootPath}\\异常截图\\{OtherName}"; }
        }


        /// <summary>
        /// 异常截图提醒文件地址
        /// </summary>
        public string ErrTxtPath
        {
            get { return $"{RootPath}\\_________{OtherName}_有异常截图_________.txt"; }
        }
    }
}
